package cn.uestc.labhms.modules.hms.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.uestc.labhms.modules.hms.entity.ClinicRecordEntity;
import cn.uestc.labhms.modules.hms.service.ClinicRecordService;
import cn.uestc.labhms.common.utils.PageUtils;
import cn.uestc.labhms.common.utils.R;



/**
 * 就诊记录表
 *
 * @author Mu.tz
 * @email Mutz@gmail.com
 * @date 2021-11-01 20:33:42
 */
@RestController
@RequestMapping("hms/clinicrecord")
public class ClinicRecordController {
    @Autowired
    private ClinicRecordService clinicRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("hms:clinicrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = clinicRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{clinicId}")
    @RequiresPermissions("hms:clinicrecord:info")
    public R info(@PathVariable("clinicId") Long clinicId){
		ClinicRecordEntity clinicRecord = clinicRecordService.getById(clinicId);

        return R.ok().put("clinicRecord", clinicRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("hms:clinicrecord:save")
    public R save(@RequestBody ClinicRecordEntity clinicRecord){
		clinicRecordService.save(clinicRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("hms:clinicrecord:update")
    public R update(@RequestBody ClinicRecordEntity clinicRecord){
		clinicRecordService.updateById(clinicRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("hms:clinicrecord:delete")
    public R delete(@RequestBody Long[] clinicIds){
		clinicRecordService.removeByIds(Arrays.asList(clinicIds));

        return R.ok();
    }

}
